<!-- 公共文件 start -->
@extends('admin.public.base')
<!-- 公共文件 end -->
<style>
    .btn_kq {
        margin: 0 auto;
        width: 200px;
        height: 200px;
        border: 0;
        border-radius: 50%;
        background-color: #00FF00;
        font-size: 36px
    }

    .btn_gb {
        margin: 0 auto;
        width: 200px;
        height: 200px;
        border: 0;
        border-radius: 50%;
        background-color: #cccccc;
        font-size: 36px
    }

    .ffftxt {
        left: 140px;
        position: absolute;
        top: 160px;
    }
</style>
@section('content')
    <div class="x-nav">
    <span class="layui-breadcrumb mbx_fl_10">
        <a href="">首页</a>
        <a href="">销售管理</a>
        <a><cite>余额验证</cite></a>
    </span>
        <a class="layui-btn layui-btn-small mbx_fr_10" style="line-height:1.6em;margin-top:3pxx"
           onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row">
            <div class="" style="width: 500px; margin-left: 50px; margin-top: 20px">
                @if($is_storeYzMoney == 1)
                    <p class="ffftxt">(点击关闭)</p>
                    <button type="button" class="btn_kq" onclick="openYz(2)">已开启</button><br><br><br>
                @else
                    <p class="ffftxt">(点击开启)</p>
                    <button type="button" class="btn_gb" onclick="openYz(1)">已关闭</button><br><br><br>
                @endif
                注：<br>
                开启后所有商户管理费余额和货款余额重置0，并补货订单开启余额验证
            </div>
        </div>
    </div>
    <script>
        function openYz(type) {
            if (type == 1) {
                var msg = "确认开启余额验证吗？？(开启后所有商户管理费余额和货款余额重置0，并补货订单开启余额验证)";
            } else {
                var msg = "确认关闭余额验证吗？？";
            }
            if (confirm(msg) == true) {
                //发异步，把数据提交给php
                $.ajax({
                    type: 'POST',
                    url: '/admin/order/storeYzMoney',
                    data: {},
                    dataType: 'json',
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                    },
                    success: function (data) {
                        if (data.code == 1) {
                            location.reload();
                        }
                    },
                    error: function (xhr, type) {
                        alert('Ajax error!')
                    }
                });
                return true;
            } else {
                return false;
            }
        }
    </script>
@endsection
